package leetcode;

public class ListNode {
    public int val;
    public ListNode next;

    ListNode(int x) {
        val = x;
    }

    @Override
    public String toString() {
        if (this == null) {
            return "";
        }
        return val + "" + (next == null ? "" : next.toString());
    }

    public ListNode append(int val) {
        next = new ListNode(val);
        return next;
    }

}